using System.ComponentModel.DataAnnotations;
using FytSoa.Common.Enum;
using SqlSugar;

namespace FytSoa.Domain.Erp;

/// <summary>
/// erp_流程审批记录
/// </summary>
[SugarTable("erp_flow_audit_log")]
public class ErpFlowAuditLog:Entity
{
    /// <summary>
    /// 使用编号例如合同等
    /// </summary>
    [Required]
    public long UseId { get; set; }
    
    /// <summary>
    /// 流程编号
    /// </summary>
    [Required]
    public long FlowId { get; set; }

    /// <summary>
    /// 流程使用编号
    /// </summary>
    [Required]
    public long FlowUseId { get; set; }

    /// <summary>
    /// 流程审批人
    /// </summary>
    [Required]
    public long PersonId { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    public FlowAuditEnum Status { get; set; } = 0;

    /// <summary>
    /// 类型标识
    /// </summary>
    [Required]
    public FlowTypeEnum Type { get; set; } = 0;

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    [Required]
    [StringLength(100)]
    public string Remark { get; set; }

    /// <summary>
    /// 驳回原因
    /// </summary>
    [SugarColumn(IsJson = true)]
    public List<ErpFlowAuditReject> Reject { get; set; } = new();

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 驳回
    /// </summary>
    public class ErpFlowAuditReject
    {
        /// <summary>
        /// 操作人
        /// </summary>
        public long EmployeeId { get; set; }

        /// <summary>
        /// 0=驳回  1=回复
        /// </summary>
        public int Type { get; set; } = 0;

        /// <summary>
        /// 原因
        /// </summary>
        public string Cause { get; set; }

        /// <summary>
        /// 时间
        /// </summary>
        public DateTime Time { get; set; }=DateTime.Now;
    }
}